package starfire.gui.defaultModelAndRenderer;

import java.io.*;

import javax.swing.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author zzzhc.starfire@gmail.com
 * @version 1.0
 */

public class DefaultFSListModel
    extends javax.swing.DefaultListModel {
  public DefaultFSListModel(File dir) {
    super();
    addSubFiles(dir);
  }

  private void addSubFiles(File dir) {
    if (dir.isFile()) {
      return;
    }
    File[] fs = dir.listFiles();
    for (int i = 0; i < fs.length; i++) {
      if (fs[i].exists() && !fs[i].isHidden() && fs[i].isDirectory()) {
        super.addElement(fs[i]);
      }
    }
    for (int i = 0; i < fs.length; i++) {
      if (fs[i].exists() && !fs[i].isHidden() && fs[i].isFile()) {
        super.addElement(fs[i]);
      }
    }
  }
}
